<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>个人信息</title>
	<meta name="renderer" content="webkit">	
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">	
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">	
	<meta name="apple-mobile-web-app-status-bar-style" content="black">	
	<meta name="apple-mobile-web-app-capable" content="yes">	
	<meta name="format-detection" content="telephone=no">	
	<link rel="stylesheet" type="text/css" href="/bsc/static/common/layui/css/layui.css" media="all">
	<link rel="stylesheet" type="text/css" href="/bsc/static/common/bootstrap/css/bootstrap.css" media="all">
	<link rel="stylesheet" type="text/css" href="/bsc/static/common/global.css" media="all">
	<link rel="stylesheet" type="text/css" href="/bsc/static/css/personal.css" media="all">
</head>
<body>
<section class="layui-larry-box">
	<div class="larry-personal">
		<header class="larry-personal-tit">
			<span>修改密码</span>
		</header><!-- /header -->
		<div class="larry-personal-body clearfix changepwd">
			<form class="layui-form col-lg-4" id="for" method="post" action="">
			 	<div class="layui-form-item">
					<label class="layui-form-label">账号</label>
					<div class="layui-input-block">  
					  	<input type="text" name="account"  autocomplete="off"  class="layui-input layui-disabled" value="${user.account }" disabled="disabled" >
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">旧密码</label>
					<div class="layui-input-block">  
					  	<input type="text" name="oldpwd" lay-verify="oldpwd" type="tel"  autocomplete="off"  class="layui-input" value="" placeholder="请输入旧密码">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">新密码</label>
					<div class="layui-input-block">  
					  	<input type="password" name="newpwd" lay-verify="newpwd"  autocomplete="off"  class="layui-input" value="" placeholder="请输入新密码">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">确认密码</label>
					<div class="layui-input-block">  
					  	<input type="password" name="pwd" lay-verify="pwd" autocomplete="off"  class="layui-input" value="" placeholder="请输入确认新密码">
					</div>
				</div>
				<div class="layui-form-item change-submit">
					<div class="layui-input-block">
						<button class="layui-btn" lay-submit="" id="but" lay-filter="demo1">立即提交</button>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</section>
<script type="text/javascript" src="/bsc/static/common/layui/layui.js"></script>
<script type="text/javascript" src="/bsc/static/common/layui/lay/dest/layui.all.js"></script>
<script type="text/javascript" src="/bsc/static/ztree/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript">
	/* layui.use(['form','upload'],function(){
         var form = layui.form();
	}); */

	layui.use(['form','layedit', 'laydate'], function(){
	  var form = layui.form()
	  ,layer = layui.layer
	  ,layedit = layui.layedit
	  ,laydate = layui.laydate;
	  var newpwd;
	  //自定义验证规则
	  form.verify({
			oldpwd: function(value){
				 if(value.length < 1){
						return '密码不能为空';
				 }else{
					 var d;
					 $.ajax({
				            type: "post",
				            url: "/bsc/systemuser/pwd",
				            data:{"pwd":value},
				            async: false,//同步提交。不设置则默认异步，异步的话，最后执行ajax
				            success: function(data){
				            	d=data;
				            	 return false;
				            }
				    }); 
						 /* return (d=='1'?'密码输入错误':false); */
						if(d=='2'){
							 return false;
						 }else{
							 return '密码输入错误';
						 }
				 }
			}, newpwd: function(value){
				newpwd=value;
			  if(value.length < 4){
				return '请输入至少4位';
			  }
			}, pwd: function(value){
			  if(value!=newpwd){
				return '两次输入不一致';
			  }
			}
			/* ,phone: [/^1[3|4|5|7|8]\d{9}$/, '手机必须11位，只能是数字！']
			,email: [/^[a-z0-9._%-]+@([a-z0-9-]+\.)+[a-z]{2,4}$|^1[3|4|5|7|8]\d{9}$/, '邮箱格式不对'] */
	  });
	  
	  //创建一个编辑器
	  layedit.build('LAY_demo_editor');
	  
	  //监听提交
	  form.on('submit(demo1)', function(data){
	    /* layer.alert(JSON.stringify(data.field), {
	      title: '最终的提交信息'
	    }) */
	     $.ajax({
            type: "post",
            url: "/bsc/systemuser/uppwd",
            data:$("#for").serialize(),
            async: false,//同步提交。不设置则默认异步，异步的话，最后执行ajax
            success: function(data){
            	top.location.href="/bsc/user/logout";
            }
          });
         /*  document.forms[0].action="/bsc/systemuser/uppwd";
			document.forms[0].submit(); */
	    //return false;
	  });
	});
</script>
</body>
</html>